package com.kai.steering.data.service.entity.domainObject;

import cn.hutool.core.bean.BeanUtil;
import com.kai.steering.data.service.entity.dto.NoteQueryDTO;
import com.kai.steering.data.service.entity.po.Note;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;

import lombok.*;

import java.io.Serializable;

/**
 * <pre>
 * 笔记 Do对象
 * </pre>
 *
 * @author kai
 * @date 2022-02-23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "NoteDO对象", description = "笔记业务实体")
public class NoteDO implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "笔记id")
    private String noteId;
    @ApiModelProperty(value = "用户_题目id")
    private String userQuestionId;
    @ApiModelProperty(value = "内容")
    private String content;
    @ApiModelProperty(value = "更新时间")
    private Date updateDatetime;
    @ApiModelProperty(value = "存在0删除1")
    private Integer usable;

    public NoteDO(String noteId, String userQuestionId) {
        this.noteId = noteId;
        this.userQuestionId = userQuestionId;
    }

    @ApiModelProperty(value = "删除日期")
    private Date deleteDatetime;

    public NoteDO(NoteQueryDTO noteQueryDTO) {
        this.convertNoteDO(noteQueryDTO);
    }
    public NoteDO(Note note) {
        this.convertNoteDO(note);
    }

    public NoteDO(String noteId, String userQuestionId, String content) {
        this.noteId = noteId;
        this.userQuestionId = userQuestionId;
        this.content = content;
        this.updateDatetime=new Date();
    }

    public NoteDO convertNoteDO(Note note){
        this.noteId=note.getNoteId();
        this.userQuestionId=note.getNoteId();
        this.content=note.getNoteId();
        this.updateDatetime=note.getUpdateDatetime();
        this.usable=note.getUsable();
        this.deleteDatetime=note.getDeleteDatetime();
        return this;
    }
    public NoteDO convertNoteDO(NoteQueryDTO noteQueryDTO){
        this.noteId=noteQueryDTO.getNoteId();
        this.userQuestionId=noteQueryDTO.getNoteId();
        this.content=noteQueryDTO.getNoteId();
        this.updateDatetime=null;

        this.deleteDatetime=null;
        return this;
    }
}